<template>
  <div class="app-container">
    <div class="top">
      <!-- <el-input style="width: 200px;" v-model="keyword" placeholder="输入搜索内容" size="small"></el-input> -->
      <el-input style="width: 200px;margin-left: 10px;" v-model="periods" placeholder="请输入期数" size="small"></el-input>
      <el-select style="margin-left: 10px;" v-model="value2" placeholder="请选择玩法" size="small" @change='selectTwo'>
        <el-option v-for="item in options2" :key="item.value" :label="item.label" :value="item.value">
        </el-option>
      </el-select>
      <div class="block">
        <el-date-picker
          style="margin-left: 10px;width: 380px;"
          @change='timeChange'
          v-model="value1"
          type="datetimerange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          size="small">
        </el-date-picker>
      </div>

      <el-button style="margin-left: 10px;" type="primary" size="small" @click="search">搜索</el-button>
      <!-- <el-button style="margin-left: 10px;" type="primary" size="small" @click="retrunSearch">全部重置</el-button> -->
    </div>

    <el-table :data="tableData" border style="width: 100%;">
      <el-table-column label="门店名" width="150" align="center">
        <template slot-scope="scope">{{scope.row.shopName}}</template>
      </el-table-column>
      <el-table-column label="玩法" width="150" align="center">
        <template slot-scope="scope">{{scope.row.type==1?'排列5':scope.row.type==2?'排列3':scope.row.type==3?'福彩3d':'大乐透'}}</template>
      </el-table-column>
      <el-table-column label="期数" width="150" align="center">
        <template slot-scope="scope">{{scope.row.period}}</template>
      </el-table-column>
      <el-table-column label="中奖注数" width="150" align="center">
        <template slot-scope="scope">{{scope.row.number}}</template>
      </el-table-column>
    <!--  <el-table-column label="订单金额" width="150" align="center">
        <template slot-scope="scope">{{scope.row.price}}</template>
      </el-table-column> -->
      <el-table-column label="日期" width="auto" align="center">
        <template slot-scope="scope">{{scope.row.periodDate}}</template>
      </el-table-column>
    </el-table>

    <el-pagination background layout="prev, pager, next" :total="total" @current-change="indexChange" style="margin-top: 30px;margin-left: 50%;">
    </el-pagination>
  </div>
</template>

<script>
  import { listAll } from '@/api/newTc'
  export default {
    name: 'oredr',
    data() {
      return {
        // keyword:'',
        periods:'',
        pageNum:1,
        type:'',
        startTime:'',
        endTime:'',
        pageSize:10,
        total: 0,
        options: [],
        value:'',
        value1: [],
        options2: [{
          value: '1',
          label: '排列5'
        }, {
          value: '2',
          label: '排列3'
        }, {
          value: '3',
          label: '福彩3D'
        }, {
          value: '4',
          label: '大乐透'
        }],
        value2:'',
        //订单列表
        tableData:[]
      }
    },
    created() {
      this.init()
    },
    methods: {
      // 搜索
      search() {
        this.init()
      },
      //时间选择
      timeChange(e){
        this.startTime = this.timeType(e[0])
        this.endTime = this.timeType(e[1])
      },
      //时间转换
      timeType(cstDate){
        const year = cstDate.getFullYear();
        const month = (cstDate.getMonth() + 1).toString().padStart(2, '0');
        const day = cstDate.getDate().toString().padStart(2, '0');
        const hours = cstDate.getHours().toString().padStart(2, '0');
        const minutes = cstDate.getMinutes().toString().padStart(2, '0');
        const seconds = cstDate.getSeconds().toString().padStart(2, '0');
        console.log(year+'-'+month+'-'+day+' '+hours+':'+minutes+':'+seconds)
        return year+'-'+month+'-'+day+' '+hours+':'+minutes+':'+seconds
      },
      //玩法选择
      selectTwo(e){
        this.type = e
      },
      //重选
      // retrunSearch(){

      // },
      //分页
      indexChange(e){
        console.log(e)
        this.pageNum = e
        this.init()
      },
      //初始化
      init(){
        this.listAll()
      },
      listAll(){
        let data = {
          pageSize:this.pageSize,
          pageNum:this.pageNum,
          periods:this.periods,
          type:this.type,
          startTime:this.startTime,
          endTime:this.endTime
        }
        listAll(data).then(res=>{
          console.log(res)
          this.tableData = res.data.list
          this.total = res.data.total
        })
      },
    }
  }
</script>

<style scoped>
  .app-container {
    margin-top: 40px;
    margin-left: 120px;
    margin-right: 120px;
    min-height: 500px;
  }
  .top {
    display: flex;
    align-items: center;
    margin-bottom: 50px;
  }

  .topSearch {
    width: 300px;
    display: flex;
    align-items: center;
  }

</style>
